API Documentation
Matrix.h
1 // Matrix.h
3 //
5 
6 namespace nkMaths
7 {
13  class Matrix : public ByteAlignedClass<16>
14  {
15  public :
16 
17  union
18  {
19  float _m [4][4] ;
20  float m [4][4] ;
21  } ;
22 
23  public :
24 
29  Matrix () ;
41  Matrix (float m00, float m01, float m10, float m11) ;
58  Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) ;
81  Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) ;
87  Matrix (const Matrix& other) ;
91  ~Matrix () ;
92 
93  // Getters
97  Vector getRow0 () const ;
101  Vector getRow1 () const ;
105  Vector getRow2 () const ;
109  Vector getRow3 () const ;
113  Vector getCol0 () const ;
117  Vector getCol1 () const ;
121  Vector getCol2 () const ;
125  Vector getCol3 () const ;
134  float get (unsigned int row, unsigned int col) const ;
135 
136  // Setters
145  void set (float val, unsigned int row, unsigned int col) ;
146 
147  // Alterations
163  Matrix getTranspose () const ;
188 
189  // Transformations
215  void getDecomposed (Vector& position, Quaternion& orientation, Vector& scale) ;
216 
224  void setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
236  void setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
248  void setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
254  void setPositionComponent (const Vector& position) ;
266  void setScaleComponent (const Vector& scale) ;
274  void setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
275 
283  Vector transform (const Vector& vector) const ;
284 
285  // Utilities
289  float getDeterminantMat2 () const ;
293  float getDeterminantMat3 () const ;
297  float getDeterminantMat4 () const ;
301  float getTraceMat3 () const ;
305  float getTraceMat3 () const ;
309  float getTraceMat4 () const ;
310 
317  void fromString (const nkMemory::StringView& str) ;
318 
319  // Operators
326  Matrix& operator= (const Matrix& other) ;
333  bool operator== (const Matrix& other) ;
340  bool operator!= (const Matrix& other) ;
347  Matrix operator+ (const Matrix& other) const ;
353  void operator+= (const Matrix& other) ;
360  Matrix operator- (const Matrix& other) const ;
366  void operator-= (const Matrix& other) ;
373  Matrix operator* (const Matrix& other) const ;
380  Vector operator* (const Vector& toApply) const ;
387  Matrix operator* (float scalar) const ;
393  void operator*= (const Matrix& other) ;
399  void operator*= (float scalar) ;
406  Matrix operator/ (float scalar) const ;
412  void operator /= (float scalar) ;
413  } ;
414 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::~Matrix
~Matrix()
nkMaths::Matrix::operator!=
bool operator!=(const Matrix &other)
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Quaternion &orientation, Vector &scale)
nkMaths::Matrix::setScaleComponent
void setScaleComponent(const Vector &scale)
nkMaths::Matrix::setPositionComponent
void setPositionComponent(const Vector &position)
nkMaths::Matrix::fromString
void fromString(const nkMemory::StringView &str)
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::operator*
Matrix operator*(const Matrix &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::setToTransformation
void setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::setToViewMatrixDirection
void setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::setToOrthographicMatrix
void setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::operator-=
void operator-=(const Matrix &other)
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::Matrix
Matrix()
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::operator==
bool operator==(const Matrix &other)
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::operator/=
void operator/=(float scalar)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m10, float m11)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::set
void set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::transform
Vector transform(const Vector &vector) const
nkMaths::Matrix::operator+
Matrix operator+(const Matrix &other) const
nkMaths::Matrix::operator-
Matrix operator-(const Matrix &other) const
nkMaths::Matrix::setOrientationComponent
void setOrientationComponent(const Quaternion &rot)
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::operator=
Matrix & operator=(const Matrix &other)
nkMaths::Matrix::Matrix
Matrix(const Matrix &other)
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Matrix::operator*=
void operator*=(const Matrix &other)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::setToPerspectiveMatrix
void setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::operator/
Matrix operator/(float scalar) const
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMaths::Matrix::operator+=
void operator+=(const Matrix &other)